package com.sangeng.controller;

import com.sangeng.annotation.SystemLog;
import com.sangeng.domain.ResponseResult;
import com.sangeng.service.ArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * ClassName: ArticleController
 * Package: com.sangeng.controller
 * Description:
 *
 * @Author hjh
 * @Create 2024/8/11 14:35
 * @Version 1.0
 */
@RestController
@RequestMapping("/article")
@Api(tags = "文章模块",description = "文章模块相关接口")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    //热门文章

    @SystemLog(businessName = "热门文章")
    @GetMapping("/hotArticleList")
    @ApiOperation(value = "热门文章接口")
    public ResponseResult hotArticleList(){
        ResponseResult result = articleService.hotArticlList();
        return result;
    }

    //分页查询文章列表
    @SystemLog(businessName = "分页查询文章列表")
    @GetMapping("/articleList")
    @ApiOperation(value = "分页查询文章列表接口")
    public ResponseResult  articleList(Integer pageNumber,Integer pageSize,Long categoryId){
        return  articleService.articleList(pageNumber,pageSize,categoryId);
    }

    //文章详情接口
    @SystemLog(businessName = "文章详情接口")
    @GetMapping("/{id}")
    @ApiOperation(value = "文章详情接口")
    @ApiImplicitParam(name = "id",value = "文章id",required = true,dataType = "Long")
    public ResponseResult getArticleDetail(@PathVariable Long id){
        return articleService.getArticleDetail(id);
    }

    //更新阅读数
    @SystemLog(businessName = "更新阅读数")
    @PutMapping("/updateViewCount/{id}")
    @ApiOperation(value = "更新阅读数接口")
    @ApiImplicitParam(name = "id",value = "文章id",required = true,dataType = "Long")
    public ResponseResult updateViewCount(@PathVariable("id") Long id){
        return articleService.updateViewCount(id);
    }
}
